package com.smart.web.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.smart.consts.AppInteractiveState;
import com.smart.consts.AppStatusData;
import com.smart.model.Loan;
import com.smart.model.LoanCond;
import com.smart.model.base.JsonModel;
@Controller
public class AppHomePageController extends BaseController{
	/**
	 * 首页获取新手推荐,最热产品,最新产品列表
	 * @param data
	 * @param request
	 * @param response
	 */
	@RequestMapping("homePage/getList")
	public void getList(String data,HttpServletRequest request, HttpServletResponse response) {
		JsonModel jsonModel = new JsonModel();
		AppStatusData statusObject = new AppStatusData();
		List<Loan> list = new ArrayList<Loan>();
		LoanCond cond=new LoanCond();
		cond.addOrderByAsc("sort");
		if (requestHandle(data, jsonModel,statusObject)) {
			String type = jsonModel.getBodyValue("type");
			if(type.equals("greenHand")) {
				cond.setRecommend(true);
			}else if(type.equals("hot")) {
				cond.setHot(true);
			}else if(type.equals("latest")) {
				cond.setLatest(true);
			}
			list = loanService.find(cond);
			statusObject = AppInteractiveState.SUCCESS_DATA;
			returnJson(response, statusObject, list);
		}
		returnJson(response,statusObject,null);
	}
	/*@RequestMapping("homePage/getList1")
	public void getList1(HttpServletRequest request, HttpServletResponse response,String type) {
		JsonModel jsonModel = new JsonModel();
		AppStatusData statusObject = null;
		List<Loan> list = new ArrayList<Loan>();
		LoanCond cond=new LoanCond();
		cond.addOrderByAsc("sort");
		//String type = jsonModel.getBodyValue("type");
		if(type.equals("greenHand")) {
			cond.setRecommend(true);
		}else if(type.equals("hot")) {
			cond.setHot(true);
		}else if(type.equals("latest")) {
			cond.setLatest(true);
		}
		list = loanService.find(cond);
		statusObject = AppInteractiveState.SUCCESS_DATA;
		returnJson(response, statusObject, list);
	}*/
}
